package thn.home.glf.kotoba.database;

import java.util.ArrayList;

import thn.org.home.lib.SQLiteDB;

import android.database.Cursor;

public class BaiDB {
	public static String TableName = "tblbai";
	public static String Filed_baiID = "baiID";
	public static String Filed_Names = "Names";
	private int baiID;
	private String Names;
	private SQLiteDB db;

	public BaiDB() {

	}

	public BaiDB(SQLiteDB db) {
		this.db =  db;
	}

	public int getBaiID() {
		return baiID;
	}

	public void setBaiID(int baiID) {
		this.baiID = baiID;
	}

	public String getNames() {
		return Names;
	}

	public void setNames(String names) {
		Names = names;
	}

	public ArrayList<BaiDB> List() {
		ArrayList<BaiDB> listdata = null;
		this.db.open();
		String[] columns = { BaiDB.Filed_baiID, BaiDB.Filed_Names };
		Cursor mCursor = this.db.query(true, BaiDB.TableName, columns, null,
				null, null, null, null, null);
		if (mCursor != null) {
			mCursor.moveToFirst();
		}
		if (mCursor.moveToFirst()) {
			listdata = new ArrayList<BaiDB>();
			do {
				BaiDB element = new BaiDB();
				element.setBaiID(mCursor.getInt(mCursor
						.getColumnIndex(BaiDB.Filed_baiID)));
				element.setNames(mCursor.getString(mCursor
						.getColumnIndex(BaiDB.Filed_Names)));
				listdata.add(element);
			} while (mCursor.moveToNext());
		}
		return listdata;

	}
}
